package org.structure.boot.demomybatis.mapper;

import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import org.structure.boot.demomybatis.entity.User;

/**
 * @version V1.0.0
 * @Title: UserMapper
 * @Package org.structure.boot.demomybatis.mapper
 * @Description: ${TODO} 此类的用途
 * @author: chuck
 * @date: 2020/6/1 11:10
 */
public interface UserMapper {

    @Insert("INSERT INTO m_user (id,name,create_time)values (#{id},#{name},#{createTime}) ")
    Integer save(User user);

    @Results(id = "baseResult",value = {
            @Result(id = true,property = "id",column = "id",jdbcType = JdbcType.VARCHAR),
            @Result(property = "name",column = "name",jdbcType = JdbcType.VARCHAR),
            @Result(property = "createTime",column = "create_time",jdbcType = JdbcType.DATE)
    })
    @Select("SELECT id ,name, create_time FROM m_user WHERE id = #{id}")
    User findById(String id);

}
